> */ public function getNodeTypes() : array { return [Class_::class, ClassMethod::class, Property::class]; } /** * @param Class_|ClassMethod|Property $node */ public function refactor(Node $node) : ?Node { $hasChanged = \false; foreach ($node->attrGroups as $attrGroup) { foreach ($attrGroup->attrs as $attr) { $newAttributeName = $this->matchNewAttributeName($attr); if (!\is_string($newAttributeName)) { continue; } $attr->name = new FullyQualified($newAttributeName); $hasChanged = \true; } } if ($hasChanged) { return $node; } return null; } /** * @param mixed[] $configuration */ public function configure(array $configuration) : void { Assert::allIsAOf($configuration, RenameAttribute::class); $this->renameAttributes = $configuration; } public function provideMinPhpVersion() : int { return PhpVersionFeature::ATTRIBUTES; } private function matchNewAttributeName(Attribute $attribute) : ?string { foreach ($this->renameAttributes as $renameAttribute) { if ($this->isName($attribute->name, $renameAttribute->getOldAttribute())) { return $renameAttribute->getNewAttribute(); } } return null; } }